package com.xtkj.stcrm.controller;

import java.util.List;


import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xtkj.stcrm.common.IConstant;
import com.xtkj.stcrm.common.JsonResult;
import com.xtkj.stcrm.pojo.Auth;
import com.xtkj.stcrm.pojo.User;
import com.xtkj.stcrm.service.IAuthService;

@Controller
@RequestMapping("/auth")
public class AuthController {

	@Autowired
	private IAuthService authService;
	
	
	@RequestMapping("/currauths")
	@ResponseBody
	public JsonResult listAuthsByCurrentUser(HttpServletRequest request) {
		
		
		
		JsonResult  json = null;
		try {
			
			User user = (User)request.getSession().getAttribute(IConstant.USER_CURRENT);
			Integer  userId = user.getUserId();
			List<Auth> auths = authService.listAuthsByCurrentUser(userId);
			
			json = new JsonResult("200", "OK", auths);
		} catch (Exception e) {
			e.printStackTrace();
			json = new JsonResult("500", e.getMessage());
		}
		
		return json;
	}
}
















